﻿#pragma once


#include "Camera.h"

class D3DX;
class D3DXRenderer;
class Object;
class Camera;
class MouseEventListener;
struct MouseEvent;

class CGame
{
public:
	typedef std::vector<Object*> ObjectList;

public:
	CGame(HWND hwnd,int width,int height);
	~CGame(void);

	bool Init();

	bool Tick(float time);
	bool Render();

	void SetMatrices();

	bool GetGameRun() const { return mGameRun; }
	void SetGameRun(bool val) { mGameRun = val; }

	D3DX* GetDx() { return mDx; }

	void AddMouseEventListener( MouseEventListener* listener );
	void DelMouseEventListener( MouseEventListener* listener );
	void ProcessMouseEventMove( MouseEvent& evt );
	void ProcessMouseEventClick( MouseEvent& evt );
	void ProcessMouseEventWheel( MouseEvent& evt );

	void AddKeyEventListener( KeyEventListener* listener );
	void DelKeyEventListener( KeyEventListener* listener );
	void ProcessKeyEvent( KeyEvent& evt );

	int GetWindowWidth() { return mWindoWidth; }
	int GetWindowHeight() { return mWindoHeight; }

	Camera* GetCamera() { return mCamera; }

private:
	HWND mHwnd;
	bool mGameRun;

	D3DX* mDx;
	D3DXRenderer* mDXRenderer;
	Camera* mCamera;
	ObjectList mObjectList;

	std::vector< MouseEventListener* > mMouseEventListener;
	std::vector< KeyEventListener* > mKeyEventListener;

	int mWindoWidth;
	int mWindoHeight;
};
